//
//  MSScoreView.m
//  MSJD
//
//  Created by xiangbo on 2018/11/22.
//  Copyright © 2018 xiangbo. All rights reserved.
//

#import "MSScoreView.h"

@implementation MSScoreView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.star = [[MSStarControl alloc] initWithFrame:CGRectMake(0.f, 0.f, 80.f, 12)];
        self.star.allowIncompleteStar = YES;
        [self addSubview:self.star];
        
        self.scoreLabel = [[UILabel alloc] init];
        self.scoreLabel.font = [UIFont systemFontOfSize:12.f];
        self.scoreLabel.textColor = UIColorHex(0x444444);
        self.scoreLabel.text = @"4.8";
        [self addSubview:self.scoreLabel];
        
        [self.star mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self);
            make.width.mas_equalTo(self.star.width);
            make.height.mas_equalTo(self.star.height);
            make.centerY.equalTo(self);
        }];
        
        [self.scoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.star.mas_right).offset(6);
            make.centerY.equalTo(self.star);
        }];
    }
    return self;
}

- (void)setScore:(NSNumber *)score{
    self.star.scorePercent = score.floatValue;
    self.scoreLabel.text = score.stringValue;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
